﻿using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace AutoBlogger.Tool
{
    internal class HotKeyControl
    {
        static int hotKeyId = 123;

        internal static int HotKeyId
        {
            get
            {
                return hotKeyId;
            }
        }

        static uint controlKey = 2;

        internal static uint ControlKey
        {
            get
            {
                return controlKey;
            }
        }

        static Keys key = Keys.Q;

        internal static Keys HotKey
        {
            get
            {
                return key;
            }
        }

        /// <summary>
        /// 注册热键的api
        /// </summary>
        /// <param name="hWnd">窗体句柄</param>
        /// <param name="id">热键ID</param>
        /// <param name="control">辅助键说明: None = 0,   Alt = 1,  crtl= 2,  Shift = 4,   Windows = 8
        /// 如果有多个辅助键则,例如 alt+crtl是3 直接相加就可以了</param>
        /// <param name="vk">热键</param>
        /// <returns></returns>
        [DllImport("user32")]
        internal static extern bool RegisterHotKey(IntPtr hWnd, int id, uint control, Keys vk);

        /// <summary>
        /// 解除注册热键的api
        /// </summary>
        /// <param name="hWnd">窗体句柄</param>
        /// <param name="id">热键ID</param>
        /// <returns></returns>
        [DllImport("user32")]
        internal static extern bool UnregisterHotKey(IntPtr hWnd, int id);
    }
}
